<template>
	<view>
		<!-- 搜索框 -->
		<view class="search" v-model="searchForm">
			<view class="search_left" @click="searchLeft">
				<text>{{tit}}</text>
				<image :class="searchList==true?'active_img':'cancle_img'" src="../static/icon/jiantou.png" mode="" />
			</view>
			<view class="search_center">
				<view>
					<image src="../static/icon/search.png" mode=""></image>
					<input type="text" value="" placeholder="搜索职位/企业/内容" v-model="searchForm.search" />
				</view>
				<view class="btn" @click="search(searchForm)">搜索</view>
			</view>
			<view class="search_lsit" :class="searchList==true?'searchActive':'cancleSearch'">
				<view @click="search_lsit_click('兼职')">兼职</view>
				<view @click="search_lsit_click('全职')">全职</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "search",
		data() {
			return {
				searchList: false,
				tit:'请选择',
				searchForm:{
					type:"",
					search:'',
					currentPage:1,
					pageSize:10
				}
			};
		},
		methods: {
			// 搜索
			search(form){
				if(form.type=="请选择"){
					form.type=''
				}
				this.getSearch(form)
			},
			// 职位搜索
			getSearch(data){
				this.$myResquest.getRecruitSearch(data).then(res=>{
					if(res.data.code==200){
						
					}
				})
			},
			// 下拉框点击事件
			search_lsit_click(data){
				this.tit=data
				if(data=='全职'){
					this.searchForm.type='jbfull'
				}
				if(data=='兼职'){
					this.searchForm.type='jbpart'
				}
				this.searchList = !this.searchList
			},
			searchLeft() {
				this.searchList = !this.searchList
			}
		}
	}
</script>

<style lang="scss">
	// 搜索框
	.search {
		position: relative;
		display: flex;
		align-items: center;
		// width: 100%;
		// min-width: 351px;
		// height: 32px;
		background: #ffffff;
		border-radius: 32rpx;
		box-shadow: 0px 0px 18rpx 0px rgba(0, 0, 0, 0.1);
		// z-index: 999;

		.search_left {
			display: flex;
			width: 102rpx;
			min-width: 102rpx;
			height: 26rpx;
			justify-content: space-between;
			padding-left: 26rpx;
			box-sizing: content-box;
			align-items: center;
			border-right: 2rpx solid #d2d2d2;

			text {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-Medium;
				font-weight: 500;
				color: #333333;
			}

			image {
				width: 22rpx;
				height: 14rpx;
				margin-right: 6rpx;

			}
		}

		.search_center {
			display: flex;
			justify-content: space-between;
			width: 100%;
			// min-width: 288px;

			view {
				display: flex;
				align-items: center;

				image {
					width: 24rpx;
					height: 24rpx;
					margin-left: 28rpx;
					margin-right: 14rpx;
				}

				.uni-input-placeholder {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #d2d2d2;
					background: #ffffff;
				}
			}

			.btn {
				display: flex;
				justify-content: center;
				align-items: center;
				min-width: 120rpx;
				height: 68rpx;
				background: #5cd1ce;
				border-radius: 34rpx;
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-Medium;
				font-weight: 500;
				text-align: left;
				color: #f4f4f4;

			}



		}

		.search_lsit {
			position: absolute;
			top: 64rpx;
			left: 0;
			background: #f2f2f2;
			// height: 62px;
			min-width: 154rpx;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
			opacity: 0;

			view {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC-Medium;
				font-weight: 500;
				text-align: left;
				color: #999999;
			}
		}
	}

	// 箭头旋转
	.active_img {
		transform: rotate(180deg);
		-ms-transform: rotate(180deg);
		/* IE 9 */
		-webkit-transform: rotate(180deg);
		/* Safari and Chrome */
	}

	.cancle_img {
		transform: rotate(0);
		-ms-transform: rotate(0);
		/* IE 9 */
		-webkit-transform: rotate(0);
		/* Safari and Chrome */
	}

	// 激活下拉框
	.searchActive {
		animation-name: searchZhankai;
		animation-duration: .5s;
		-webkit-animation-name: searchZhankai;
		-webkit-animation-duration: .5s;
		/* Safari 和 Chrome */
		overflow: hidden;
		animation-fill-mode: forwards;
	}

	@keyframes searchZhankai {
		0% {
			height: 0;
			opacity: 0;
		}

		100% {
			height: 110rpx;
			opacity: 1;
		}
	}

	@-webkit-keyframes searchZhankai

	/* Safari and Chrome */
		{
		0% {
			height: 0 !important;
			opacity: 0;
		}

		100% {
			height: 200rpx !important;
			opacity: 1;
		}
	}

	.cancleSearch {
		height: 0;
		animation-name: c_Search;
		animation-duration: 0;
		/* Safari and Chrome */
		-webkit-animation-name: c_Search;
		-webkit-animation-duration: 0;
		/* Safari 和 Chrome */
		overflow: hidden;
		animation-fill-mode: forwards;
	}

	@keyframes c_Search {
		0% {
			height: 110rpx;
			opacity: 1;
		}

		100% {
			height: 0px;
			opacity: 0;
		}
	}

	@-webkit-keyframes c_Search

	/* Safari and Chrome */
		{
		from {
			height: 110rpx;
			opacity: 1;
		}

		to {
			height: 0px;
			opacity: 0;
		}
	}
</style>
